import request from '@/utils/request'

// 获取系统配置列表
export function getConfigList(params) {
    return request.get('/api/config/list', params)
}

// 获取配置详情
export function getConfigDetail(id) {
    return request.get(`/api/config/${id}`)
}

// 创建配置
export function createConfig(data) {
    return request.post('/api/config', data)
}

// 更新配置
export function updateConfig(id, data) {
    return request.put(`/api/config/${id}`, data)
}

// 删除配置
export function deleteConfig(id) {
    return request.delete(`/api/config/${id}`)
}

// 批量删除配置
export function batchDeleteConfig(ids) {
    return request.delete('/api/config/batch', { ids })
}

// 获取配置分类
export function getConfigCategories() {
    return request.get('/api/config/categories')
}

// 导出配置
export function exportConfig(params) {
    return request.get('/api/config/export', params, { responseType: 'blob' })
}

// 导入配置
export function importConfig(data) {
    return request.post('/api/config/import', data, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 获取环境配置
export function getEnvConfig() {
    return request.get('/api/config/env')
}

// 更新环境配置
export function updateEnvConfig(data) {
    return request.put('/api/config/env', data)
}

// 重置配置为默认值
export function resetConfig(category) {
    return request.post(`/api/config/reset/${category}`)
}